Model-First in the Entity Framework
So I finally had the situation come up to do a model-first approach to Entity Framework (EF). It was shockingly simple. Normally I design my databases first and go from there, this time I did my EF model. Now this was just a simple four entity deal but I thought it would be a great Hello Model-First.
You simply create your entities in the designer, adding properties and adjusting their properties. You know, like indicating someNum is an int32 instead of the default string, if something can be null, default values and so on. You also add your associations. Then you generate database from model. I did this by right clicking the design surface and clicking on Generate Database from Model… This will create a SQL script that you can run against your database. In my case I did create an empty database with a SQL user before hand that I used in my connection information for generating the database.
If you still think it is harder than that, you can read this great article by Microsoft. I wanted to look it up and make sure I did not leave something out and found that article. I still suggest you look over the article. It goes into much more detail than my short text, and they include screen shots.
One thing I did go back and do was change the name of that connection. Visual Studio named it MyPartModelObjectContainer (or something close to that), where MyPart was basically what I named the Model. This was simple to do as well. You rename it int eh connectionString area of your web.config and in the properties of the model.edmx file. You can see its properties by just clicking on the design surface, not an entity or anything, just on the empty space.