How can I make an Database Model edmx file that would let me add GeoLocation column to it from design database that would let me generate / reverse engeneering from database.
This one implies that I would modify it by hand.
Do I need to install a plugin for visual studio ? Do I need to find an open source entity generation tool that would help me?
p.s. i am using thisADO.net Poco Generator
I use SQL server 2008 and .net framework 4.0
p.s. 2 What about this reference
p.s. 3 Here on MSDN are some facts about not supporting this feature http://social.msdn.microsoft.com/Forums/en-AU/sqlspatial/thread/34866400-91e5-4af5-9fee-f7f369aa6a61
As far as I now the geolocation support in the Entity Framework will be released with .NET 4.5, so until then you will have to do it manually.
The second reference you provide should help you out. What the author describes is a way to store the data in the database, make sure it stays up to date with some triggers and then in the partial class in your code define a property that will convert the data field from your database to actual LatLong data.
Related
i am learning how to work with asp .net because i need to but as i am following the database first approach http://www.asp.net/mvc/overview/getting-started/database-first-development/generating-views
& after i generated the models with ado .net the way it's shown i cannot find a context class, there is not a single one i added one manually, just to see if it might work, but still nothing & i was wondering why
i am using vs 13 free community & EF 6
thank you in advance
EDITÂ :
I fixed it after re-making the steps & now it appears
thank you for your help it brought me the idea to do so
PS : I think the issue was due to me having an older version of SSDT & i had to update it after bringing in the DB due to failure when building project
At your link, on page 'Creating the Web Application and Data Models'.
He says this:
'The ContosoModel.Context.cs file contains a class that derives from the DbContext class, and provides a property for each model class that corresponds to a database table. The Course.cs, Enrollment.cs, and Student.cs files contain the model classes that represent the databases tables. You will use both the context class and the model classes when working with scaffolding.'
Can't you find it here?
I have data stored in a MySQL database and I'm accessing it through entity framework 6. What I want to do is to extract the data and store it in a server-independent manner, so that I can use this data in the future for bootstraping of a larger database (where the data from MySQL is only a small portion of). The target database will not be MySQL.
The MySQL data was there before, so I used Database First. For the new database I use Code First. The MySQL data also needs some clean-ups, what is done in code. So the workflow is:
Read data from MySQL with Entity Framework database first
Optimize/enhance/correct it in code
Store in another database using code first
So my first thought was using SQLite, but sadly, Code First is not supported.
Using some other format (i.e. XML/DataSets/CSV) to store the data would require me to reimplement the import code.
Right now I didn't find another embedded database with Entity Framework support. As Entity Framework is meant for relational databases, I would say that Redis (or other NoSQL dbs) won't do the trick.
I also thought if "converting" H2 using IKVM.NET and then using H2 as SQLite replacement would be an option -- but there's the risk that this might fail due to some internal dependency not supported by IKVM.NET.
So I would be glad to get answers to the following questions:
Would the H2 way work? Is there even a stable/working ADO.NET provider?
I wouldn't care much about the local storage format (could also be JSON etc.) -- is there anything not-SQL, but providing Enitity Framework support?
Did I miss something? Is there a way I just didn't see yet?
Here are some related questions I stumbled upon which deal with the possibility of using Entity Framework to use files:
Entity Framework with text files (no database!)
A list of Entity Framework providers for various databases
Entity Framework with XML Files
Microsoft Entity Framework using a flat file as a data source
There is no complete solution, but there are many ready-made parts:
This project wraps the compiled Jar of H2 after IKVM.Net
with classes that implement the ADO.Net interface
to allow for easy use in .Net projects:
https://code.google.com/p/h2sharp/
EF provider for SharpHSQL (which doesn't work, because, SharpHSQL is too old, it's port of Hypersonic 1.4):
https://github.com/ArsenShnurkov/SharpHSQL/tree/master/src/SharpHsql.Linq
here is the description of build process:
https://groups.google.com/forum/#!topic/h2-database/QAvFqbyd4_0
https://code.google.com/p/h2sharp/wiki/BuildingH2Sharp
The authors of above code did a great job of writing such huge amount, so i think it's nothing wrong with writing some more to finish your task.
Sorry if this is a totally noob question but I just can't seem to find a starting point on this.
From what I've gathered so far SSDT was developed with the idea that it would be used in a different project that that of the main app for database related coding. I figured that instead of complaining about how much I like the old version back, I'd try things their way and see how well it goes but I can't seem to get a handle on where to begin over here.
Basically I want to use a code first approach and create a database from a designer. If I'm going to create a new project to handle the entity framework, what type of project should it be? a C# class library, WPF.. something else?
I'm not sure if it's of any relavance but the app I'm working on is a WPF app and the database is MySQL.
If you want to use a code-first approach, then that means that the database will be generated by the code. Thus, you will not have a separate database-project, since that would mean that your database is kept in two places. Therefore, your options are:
Use code-first. This usually means a class library (although asp.net mvc usually has the context with entities in the asp.net mvc project, let's call that an exception to the rule). The class library will contain classes with which your database will be generated.
Use a database project, an SSDT project. Your database will be defined here, and when you deploy this project the database will be generated/updated.
Note: AFAIK an SSDT project is specific to SQL Server, so since you are using a MySql database it is not an option.
I just tried that out, and I also found that If I changed EF model and want to regenerate the database from model , all existing data in database will lost.
Is there any way to fix that, as this always happens during the development.
Check out Entity Designer Database generation powerpack
it's a visual studio add on from microsoft, which let's you modify your db schema without wiping your data.
James Gaunt basically nailed it - generate the schema in a new database and use schema update tools. You don't necessarily need to buy anything there are schema and data compare and migrate tools in Visual Studio under the "Data" Menu.
Try Devart Entity Developer. We offer the database synchronization functionality for Entity Framework and LINQ to SQL models, see this article for details.
In EJB 3.0 you can write your domain objecs, then convert them into entitities (adding #Entity attribute, etc.) and underlying JPA mechanism (let's say Hibernate) can automaticly generate db schema. What's better it will also update db when you update you domain model in Java code.
I'm looking for equivalent of that functionality on .NET platform. Is is possible with ADO.NET Entity Framework?
DataObjects.Net also automatically generates and upgrades database schema according to domain model. But the most interesting thing is how to upgrade stored data if model and database schema are changed. Is it possible to do it on entity level, rather then using low-level SQL?
Mindscape LightSpeed supports this - full schema round tripping with model first or database first development. It is a commercial product but there is a free version for small databases.
As mentioned, Entity Framework will add some of these features in their next release but that is some time away.
Details of the LightSpeed designer with the model first support
Active Record is the way forward! You mark up your objects with attributes and from there you can generate the database schema or the database itself. There is also a tool called Active Writer which allows you to draw the models and it writes the codes with the correct attributes for you.
It is essentially a wrapper for NHibernate but it makes things a bit easier as you do the mapping on the objects rather than in XML documents.
We have used this on several projects and found it to be a fast way of implementing complex systems.
Yes - in the future :-) The current Entity Framework doesn't support the "domain-first" approach - but the next version (EF v4) will. This will ship with .NET 4.0 / Visual Studio 2010 - but don't ask me, when! I don't know (neither does Microsoft).
Marc
NHibernate is a .NET port of Hibernate, and I think it includes tools for generating database schema for your entities.
There are third party frameworks that do this in .NET today.