开发者

How to configure entity framework metadata locations for a web application

开发者 https://www.devze.com 2023-01-15 17:55 出处:网络
I am trying to configure Entity Framework 4 in the Web.config file using this ConnectionString ... metadata=

I am trying to configure Entity Framework 4 in the Web.config file using this ConnectionString

...
metadata=
         res://*/CmsEntityDataModel.csdl|
         res://*/CmsEntityDataModel.ssdl|
         res://*/CmsEntityDataModel.msl;
....

I would like remove the "*" and ad开发者_运维问答d the actual path for my dll file. How to find the path for a dll in Visual Studio with no add-on?

Thanks


I've written a long explanation of EF metadata paths; you might find it helpful to read it.

You can replace the * with an assembly name, which might or might not be a strong name, like this:

<add name="MyEntities" connectionString="metadata=
        res://Simple Mvc.Data.dll/Model.csdl|
        res://Simple Mvc.Data.dll/Model.ssdl|
        res://Simple Mvc.Data.dll/Model.msl;provider= <!-- ... -->


res://*/CmsEntityDataModel.csdl is a resource location, when you enter the actual path it points to a file on disk. This means that when deploying you need to have the file at that location on disk as well.

Having the metadata as an embedded resource and using the resource location is what I'd do, unless you have to be able to swap it out at some point without changing the dll.

See MSDN for more info

0

精彩评论

暂无评论...
验证码 换一张
取 消